﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using PccCommonForC;
using bs_ShowRoom;
namespace ShowRoom.admin.control
{
    public partial class MenuAdminLeft : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                GetMenu();
            }
        }
        private void GetMenu()
        {
            Literal1.Text = LoadMenu();
        }
        private string LoadMenu()
        {
            string menu = "";
            string user_id = "0";
            if (Session["user_id"] != null || Session["userId"] != "")
                user_id = Session["user_id"].ToString().Trim();

            string type="0";
            if (user_id == "1")
                type = "4";
            DataTable dt_menu = GetMenuDetail(user_id, type);
            //menu += "<ul class='sub_category'>";
            foreach (DataRow dr1 in dt_menu.Rows)
            {                  
                menu += "<li>";
                menu += "<a href='" + dr1["link"] + "'>" + dr1["mn_nm"] + "</a>";
                menu += "</li>";
            }
            
            return menu;
        }
        private DataTable GetMenuDetail(string user_id, string Type)
        {
            bs_menu mybs = new bs_menu(ConfigurationManager.ConnectionStrings["ShowRoomConnectionString"].ToString());
            PccMsg myMsg = new PccMsg();
            myMsg.CreateFirstNode("user_id", user_id);
            myMsg.CreateFirstNode("Type", Type);
            DataSet ds = mybs.DoReturnDataSet("GETPOWESUSER", myMsg.GetXmlStr, "");

            DataTable dt = new DataTable();
            if (ds.Tables.Count > 0)
                dt = ds.Tables[0];

            return dt;

        }
    }
}